package com.atguigu.spzx.pay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.atguigu.spzx.pay.properties.AlipayProperties;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: AlipayConfig
 * Package: com.atguigu.spzx.pay.config
 * Description:
 *
 * @Author 刘强
 * @Create 2024/7/19 19:40
 * @Version 1.0
 */
@Configuration
public class AlipayConfig {
    @Resource
    private AlipayProperties alipayProperties;
    // 初始化阿里支付客户端
    @Bean
    public AlipayClient alipayClient(){
        return new DefaultAlipayClient(alipayProperties.getServerUrl(),alipayProperties.getAppId(),alipayProperties.getPrivateKey(),
                alipayProperties.getFormat(),alipayProperties.getCharset(),alipayProperties.getAlipayPublicKey());
    }
}
